home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 2000 November: Tool Chest / Dev.CD Nov 00 TC Disk 2.toast / pc / sample code / quicktime / quicktime vr / vrmakeobject / vrmakeobject.h < prev    next >
Encoding:
Text File  |  2000-09-28  |  5.7 KB  |  161 lines

  1. //////////
  2. //
  3. //    File:        VRMakeObject.h
  4. //
  5. //    Contains:    Code for creating a QuickTime VR object movie from a linear QuickTime movie.
  6. //
  7. //    Written by:    Tim Monroe
  8. //                Based on MakeQTVRObject code by Pete Falco and Michael Chen (and others?).
  9. //
  10. //    Copyright:    © 1991-1998 by Apple Computer, Inc., all rights reserved.
  11. //
  12. //    Change History (most recent first):
  13. //
  14. //       <1>         20/01/98    rtm        first file
  15. //       
  16. //////////
  17.  
  18. #include <Endian.h>
  19. #include <FixMath.h>
  20. #include <Math.h>
  21. #include <ImageCompression.h>
  22. #include <Movies.h>
  23. #include <QuickTimeComponents.h>
  24. #include <QuickTimeVR.h>
  25. #include <QuickTimeVRFormat.h>
  26. #include <Script.h>
  27. #include <Sound.h>
  28.  
  29. #include "ComApplication.h"
  30.  
  31. #if TARGET_OS_MAC
  32. #include "MacFramework.h"
  33. #endif
  34.  
  35. #if TARGET_OS_WIN32
  36. #include "WinFramework.h"
  37. #endif
  38.  
  39. //////////
  40. // macros
  41. //////////
  42.  
  43. #define FloatToFixed(a)                     ((Fixed)((float)(a) * fixed1))
  44.  
  45.  
  46. //////////
  47. //
  48. // constants
  49. //
  50. //////////
  51.  
  52. #define kDefaultNodeID                    1                            // default node ID
  53. #define kQTVRVersion1                    (long)1
  54. #define kQTVRVersion2                    (long)2
  55. #define kObjectFormat1x0DataType        FOUR_CHAR_CODE('NAVG')
  56.  
  57. #define kObjSaveMoviePrompt                "Save object movie file as:"
  58. #define kObjSaveMovieFileName            "Untitled.mov"
  59.  
  60. // default object settings;
  61. // a real application would let the user select these values interactively
  62. // (perhaps by displaying a dialog box with a bunch of edit text items....)
  63.  
  64. #define kDefaultNumOfColumns            (UInt16)36
  65. #define kDefaultNumOfRows                (UInt16)13
  66. #define kDefaultLoopSize                (UInt16)1
  67. #define kDefaultLoopTicks                (UInt16)0                    // for looping object: display next frame as quickly as possible    
  68. #define kDefaultFrameDuration            (UInt16)60
  69. #define kDefaultMovieType                (UInt16)kGrabberScrollerUI
  70. #define kDefaultViewStateCount            (UInt16)1
  71. #define kDefaultDefaultViewState        (UInt16)1
  72. #define kDefaultMouseDownViewState        (UInt16)1
  73.  
  74. // version 1.0 uses Fixed for some of its data items, while version 2.x uses Float32;
  75. // we'll define our default settings using Float32 and, when necessary, convert to Fixed using the FloatToFixed macro defined above
  76. #define kDefaultFieldOfView                (Float32)180.0
  77. #define kDefaultMinFieldOfView            (Float32)8.0
  78. #define kDefaultStartPan                (Float32)0.0    
  79. #define kDefaultEndPan                    (Float32)360.0
  80. #define kDefaultStartTilt                (Float32)90.0
  81. #define kDefaultEndTilt                    (Float32)-20.0
  82. #define kDefaultInitialPan                (Float32)180.0                // not used; we calculate the initial pan angle from the source movie's current time
  83. #define kDefaultInitialTilt                (Float32)0.0                // not used; we calculate the initial tilt angle from the source movie's current time
  84. #define kDefaultMouseMotionScale        (Float32)180.0    
  85. #define kDefaultDefaultViewCenterH        (Float32)0.0    
  86. #define kDefaultDefaultViewCenterV        (Float32)0.0    
  87. #define kDefaultViewRate                (Float32)1.0    
  88. #define kDefaultFrameRate                (Float32)1.0
  89.     
  90. #define kDefaultAnimationSettings        (UInt32)0    
  91. #define kDefaultControlSettings            (UInt32)(kQTVRObjectWrapPanOn | kQTVRObjectCanZoomOn | kQTVRObjectTranslationOn)    
  92.  
  93.  
  94. //////////
  95. //
  96. // data types
  97. //
  98. //////////
  99.  
  100. // version 1.0 data types
  101.  
  102. #if PRAGMA_ALIGN_SUPPORTED
  103. #pragma options align=mac68k
  104. #endif
  105.  
  106. // object file format record:
  107. // this defines the structure of the 'NAVG' user data item
  108.  
  109. typedef struct {
  110.     short            versionNumber;        // version number; always 1
  111.     short            numberOfColumns;    // number of columns in movie
  112.     short            numberOfRows;        // number rows in movie
  113.     short            reserved1;            // reserved; must be 0
  114.     short            loopSize;            // number of frames shot at each position
  115.     short            frameDuration;        // the duration of each frame
  116.     short            movieType;            // kStandardObject, kObjectInScene, or kOldNavigableMovieScene
  117.     short            loopTicks;            // number of ticks before next frame of loop is displayed
  118.     Fixed            fieldOfView;        // 180.0 for kStandardObject or kObjectInScene, actual degrees for kOldNavigableMovieScene.
  119.     Fixed            startHPan;            // start horizontal pan angle, in degrees
  120.     Fixed            endHPan;            // end horizontal pan angle, in degrees
  121.     Fixed            endVPan;            // end vertical pan angle, in degrees
  122.     Fixed            startVPan;            // start vertical pan angle, in degrees
  123.     Fixed            initialHPan;        // initial horizontal pan angle, in degrees (poster view)
  124.     Fixed            initialVPan;        // initial vertical pan angle, in degrees (poster view)
  125.     long            reserved2;            // reserved; must be 0
  126. } QTVRObjectFileFormat1x0Record, *QTVRObjectFileFormat1x0Ptr;
  127.  
  128. #if PRAGMA_ALIGN_SUPPORTED
  129. #pragma options align=reset
  130. #endif
  131.  
  132.  
  133. //////////
  134. //
  135. // function prototypes
  136. //
  137. //////////
  138.  
  139. void                        VRObject_PromptUserForMovieFileAndMakeObject (void);
  140. OSErr                        VRObject_CreateVRWorld (QTAtomContainer *theVRWorld, QTAtomContainer *theNodeInfo, OSType theNodeType);
  141. OSErr                        VRObject_CreateObjectTrack (Movie theMovie, Track theObjectTrack, Media theObjectMedia);
  142. OSErr                        VRObject_CreateQTVRMovieVers1x0 (FSSpec *theObjMovSpec, FSSpec *theSrcMovSpec);
  143. OSErr                        VRObject_CreateQTVRMovieVers2x0 (FSSpec *theObjMovSpec, FSSpec *theSrcMovSpec);
  144. OSErr                        VRObject_MakeObjectMovie (FSSpec *theMovieSpec, FSSpec *theDestSpec, long theVersion);
  145. OSErr                        VRObject_GetPanAndTiltFromTime (TimeValue theTime,
  146.                                                             TimeValue theFrameDuration,
  147.                                                             short theNumColumns,
  148.                                                             short theNumRows,
  149.                                                             short theLoopSize,
  150.                                                             Float32 theStartPan,
  151.                                                             Float32 theEndPan,
  152.                                                             Float32 theStartTilt,
  153.                                                             Float32 theEndTilt,
  154.                                                             Float32 *thePan, 
  155.                                                             Float32 *theTilt);
  156. OSErr                        VRObject_ImportVideoTrack (Movie theSrcMovie, Movie theDstMovie, Track *theImageTrack);
  157. OSErr                        VRObject_SetControllerType (Movie theMovie, OSType theType);
  158. OSErr                        VRObject_AddStr255ToAtomContainer (QTAtomContainer theContainer, QTAtom theParent, Str255 theString, QTAtomID *theID);
  159. void                        VRObject_ConvertFloatToBigEndian (float *theFloat);
  160.  
  161.